<template>
  <div class="bar-gadget-css" style="width:100;height:100%" :id="id">
    <Portal to="right-disable" style="width:100;height:100%"
            v-loading="loading"
            :disabled="!queryModelDefaultSetting.showSetting">
      <DashboardInterceptConsumer :gadgetId="id"
                                  shadow="never"
                                  @mouseenter="mouseenter(true)"
                                  @mouseleave="mouseenter(false)"
                                  style="width:100%;height: 100%;border:0"
                                  class="aui-card--fill">
        <el-card shadow="never"
                 style="width:100%;height: 100%;border:0"
                 class="aui-card--fill">
          <div style="width:100%;height:100%;">
            <div class="cardHeader"
                 @mouseenter="mouseenter(true)"
                 @mouseleave="mouseenter(false)"
                 v-if="(widgetName && widgetName.trim().length>0) || (gadgetSetting&&gadgetSetting.headerDescription && gadgetSetting.headerDescription.trim().length>0)">
              <GadgetTitle :gadgetSetting="gadgetSetting"
                           :widgetName="widgetName"></GadgetTitle>
              <div>
                <MoreMenu :slicer='slicer'
                          :fitToHeight='fitToHeight'
                          :gadgetId='id'
                          :gadgetType='gadgetInfo.com'
                          @updateQuery="query"
                          :widgetName="widgetName"
                          :businessType="gadgetInfo.businessType"
                          :id="gadgetInfo.id"
                          @showQueryModel="showQueryModel"
                          @fullScreen="fullScreen" />
              </div>
            </div>
            <div class="control-section control-section2">
              <div class=content-wrapper
                   style="width:100%;height:100%;">
                <div v-if="isHasData"
                     :id="selfGadgetUuid"
                     style="width:100%;height:100%;"></div>
                <div v-else
                     class="gadget-no-newdata">
                    <div class="widgets-no-data">
                    <div :style="{'fontSize':fontSizeStr1}">{{$t('custom.component.gadget.nodata')}}</div>
                    <!-- <div class="widgets-tip"> <a :href="widgetNoDataWiki"  :style="{'fontSize':fontSizeStr2}"
                         target="black">{{$t('custom.component.gadget.nodatatip')}}</a> </div> -->
                  </div>
                </div>
              </div>
            </div>
          </div>
        </el-card>
        <Lastupdatetime v-if="currentTime"
                        :currentTime="currentTime"
                        :linkedDatasetList="linkedDatasetList"
                        :errorStatus="errorStatus"
                        @updateQuery="query()"></Lastupdatetime>
      </DashboardInterceptConsumer>
    </Portal>
    <model :showSetting="queryModelDefaultSetting.showSetting"
           @queryModelClosed="queryModelClosed"
           :dataInfo="queryModelDefaultSetting.dataInfo"
           :updateGadget="upgradeGadgetSetting"
           :slicer='slicer' />
    <DrillThrough :gadgetId='id'
                  :pageId='pageId'
                  :slicer="slicer"
                  :queryId="queryId"
                  ref="drill-through"
                  :widgetName='widgetName' />
    <div style="position:absolute;left:9999px;">
      <component v-for="(item, index) in formatComponentList"
                 :key="index"
                 :is="item"
                 :ref="item"
                 gadgetType='notgridgadget' />
    </div>
  </div>
</template>

<script>
import mixinGadgetViewModule from '@/mixins/gadget-view-module'
import Lastupdatetime from '@/components/last-update-time/index.vue'
import { defaultGadgetSettingList } from '@/utils/data-json'
import mixinFormatViewModule from '@/mixins/format-gadget-view-module'
import * as Echarts from 'echarts'
import { getUUID } from '@/utils'
import ecStat from 'echarts-stat'
import { splitLable } from '@/utils/common'
export default ({
  mixins: [mixinGadgetViewModule, mixinFormatViewModule],
  components: { Lastupdatetime, model: () => import('@/components/gadget/query-model/query-model') },
  data: function () {
    // var hours = ['12a', '1a', '2a', '3a', '4a']
    // // prettier-ignore
    // var days = ['Saturday', 'Friday', 'Thursday',
    //   'Wednesday', 'Tuesday']
    // // prettier-ignore
    // var data = [[0, 0, 5], [1, 1, 6], [2, 2, 7], [3, 3, 8], [4, 4, 9]]
    return {
      selfGadgetUuid: getUUID(),
      repeatNumber: 0,
      chartOption: {
        tooltip: {},
        visualMap: {
          calculable: true,
          min: 0,
          max: 10,
          inRange: {
            color: [
              '#313695',
              '#4575b4',
              '#74add1',
              '#abd9e9',
              '#e0f3f8',
              '#ffffbf',
              '#fee090',
              '#fdae61',
              '#f46d43',
              '#d73027',
              '#a50026'
            ]
          }
        },
        xAxis3D: {
          type: 'category',
          data: [],
          name: '',
          axisLabel: {}
        },
        yAxis3D: {
          type: 'category',
          data: [],
          name: '',
          axisLabel: {}
        },
        zAxis3D: {
          type: 'value',
          name: '',
          axisLabel: {}
        },
        grid3D: {
          boxWidth: 200,
          boxDepth: 80,
          light: {
            main: {
              intensity: 1.2
            },
            ambient: {
              intensity: 0.3
            }
          }
        },
        series: [
          {
            type: 'bar3D',
            data: [],
            shading: 'color',
            label: {
              show: true,
              fontSize: 16,
              borderWidth: 1
            },
            itemStyle: {
              opacity: 1
            },
            emphasis: {
              label: {
                fontSize: 20,
                color: '#900'
              },
              itemStyle: {
                color: '#900'
              }
            }
          }
        ]
      },
      chartDom: null,
      currentTime: null,
      queryData: [],
      queryFields: [],
      theme: 'Material',
      dataSource: [{ name: 'a', data: [{ x: 0, y: 0 }] }],
      gadgetSetting: null,
      loading: false,
      chartWidth: '600px',
      dataSource1: null,
      queryModelDefaultSetting: {
        showSetting: false,
        dataInfo: {
          businessId: this.pageId,
          gadgetId: this.id,
          gadgetType: 'bar3dchartgadget',
          gadgetSetting: this._.find(defaultGadgetSettingList, { gadgetType: 'bar3dchartgadget' }).gadgetSetting
        }
      },
      queryId: '',
      queryDrillthrough: {},
      queryDrillthroughList: [],
      selectFields: [],
      widgetName: '',
      conditionFormat: [],
      linkedDatasetList: []
    }
  },
  beforeCreate () {
    // this.$options.components.model = () => import('@/components/gadget/query-model/query-model')
  },
  created () {
    this.gadgetHeight = (this.gadgetInfo.h * 20) - 45
    // this.query()
    this.subscribeMessage('runReport', () => {
      this.query(this.refreshCount > 0 ? 'auto' : false)
      this.refreshCount = this.refreshCount + 1
    })
    this.$store.state.isWidget = false
  },
  methods: {
    updateChart (originData) {
      var _self = this
      _self.chartDom = document.getElementById(`${_self.selfGadgetUuid}`)
      if (!_self.chartDom) {
        setTimeout(() => {
          _self.repeatNumber++
          _self.updateChart(originData)
        }, 1000)
      } else if (!Array.isArray(originData) || (Array.isArray(originData) && originData.length === 0)) {
        Echarts.init(_self.chartDom).dispose()
      } else {
        // _self.chartOption = _self.$options.data.call(_self).chartOption
        _self.repeatNumber = 0
        let myChart = Echarts.init(_self.chartDom, this.globalTheme)
        let arrX = this._.uniqBy(originData, _self.gadgetSetting.xaxis3d).map(i => i[_self.gadgetSetting.xaxis3d])
        if (_self.gadgetSetting.datasetOrderBy && _self.gadgetSetting.datasetOrderBy.length > 0) {
          var resX = _self.gadgetSetting.datasetOrderBy.find(i => i.alias === _self.gadgetSetting.xaxis3d)
          if (resX) {
            arrX.sort(function (a, b) { return resX.sort === 'ASC' ? a - b : b - a })
          }
        }
        let arrY = this._.uniqBy(originData, _self.gadgetSetting.yaxis3d).map(i => i[_self.gadgetSetting.yaxis3d])
        if (_self.gadgetSetting.datasetOrderBy && _self.gadgetSetting.datasetOrderBy.length > 0) {
          var resY = _self.gadgetSetting.datasetOrderBy.find(i => i.alias === _self.gadgetSetting.yaxis3d)
          if (resY) {
            arrY.sort(function (a, b) { return resY.sort === 'ASC' ? a - b : b - a })
          }
        }
        _self.chartOption.xAxis3D.data = arrX
        _self.chartOption.xAxis3D.name = this.gadgetSetting.xaxis3dname
        _self.chartOption.yAxis3D.data = arrY
        _self.chartOption.yAxis3D.name = this.gadgetSetting.yaxis3dname
        _self.chartOption.zAxis3D.name = this.gadgetSetting.zaxis3dname
        _self.chartOption.series[0].data = []
        _self.chartOption.visualMap.max = Number(this.gadgetSetting.maxvalue)
        _self.chartOption.visualMap.min = Number(this.gadgetSetting.minvalue)
        _self.chartOption.visualMap.calculable = this.gadgetSetting.calculable
        _self.chartOption.xAxis3D.axisLabel.formatter = (value) => {
          return `${splitLable(_self.setFormatFunctionForChart(_self.queryFields, value, _self.gadgetSetting.xaxis3d))}`
        }
        _self.chartOption.yAxis3D.axisLabel.formatter = (value) => {
          return `${splitLable(_self.setFormatFunctionForChart(_self.queryFields, value, _self.gadgetSetting.yaxis3d))}`
        }
        _self.chartOption.zAxis3D.axisLabel.formatter = (value) => {
          return `${splitLable(_self.setFormatFunctionForChart(_self.queryFields, value, _self.gadgetSetting.zaxis3d))}`
        }
        _self.chartOption.tooltip.formatter = (params) => {
          return `${_self.gadgetSetting.xaxis3d}: ${_self.setFormatFunctionForChart(_self.queryFields, originData[params.dataIndex][_self.gadgetSetting.xaxis3d], _self.gadgetSetting.xaxis3d)} <br /> ${_self.gadgetSetting.yaxis3d}: ${_self.setFormatFunctionForChart(_self.queryFields, originData[params.dataIndex][_self.gadgetSetting.yaxis3d], _self.gadgetSetting.yaxis3d)}<br />
                 ${_self.gadgetSetting.zaxis3d}: ${_self.setFormatFunctionForChart(_self.queryFields, params.value[2], _self.gadgetSetting.zaxis3d)}`
        }
        // let arrX = this._.uniqBy(originData, _self.gadgetSetting.xaxis3d).map(i => i[_self.gadgetSetting.xaxis3d])
        // let arrY = this._.uniqBy(originData, _self.gadgetSetting.yaxis3d).map(i => i[_self.gadgetSetting.yaxis3d])
        originData.forEach((item, index) => {
          let indexX = arrX.findIndex(ii => ii === item[_self.gadgetSetting.xaxis3d])
          let indexY = arrY.findIndex(ii => ii === item[_self.gadgetSetting.yaxis3d])
          let temp = [indexX, indexY, item[this.gadgetSetting.zaxis3d]]
          _self.chartOption.series[0].data.push(temp)
        })
        // originData.forEach((item, index) => {
        //   let temp = [index, index, item[this.gadgetSetting.zaxis3d]]
        //   _self.chartOption.series[0].data.push(temp)
        // })
        _self.chartOption.series[0].label.show = this.gadgetSetting.showlabel
        _self.chartOption.series[0].label.formatter = (params) => {
          return `${_self.setFormatFunctionForChart(_self.queryFields, params.value[2], this.gadgetSetting.zaxis3d)}`
        }
        myChart.setOption(_self.chartOption)
        myChart.on('click', params => {
          _self.setDrillThroughInfo(params, 'bar3dchartgadget', originData, this.gadgetSetting)
        })
        this.$erd.listenTo(this.chartDom, element => {
          this.$nextTick(() => {
            this.resized()
          })
        })
      }
    },
    setGoal () {
      this.chartOption.series.unshift({
        data: [Number(this.gadgetSetting.goal)],
        type: 'line',
        silent: true,
        symbolSize: 0,
        markLine: {
          silent: true,
          data: this.gadgetSetting.type === 'Bar' ? [
            { name: 'Goal', xAxis: Number(this.gadgetSetting.goal) }
          ] : [
            { name: 'Goal', yAxis: Number(this.gadgetSetting.goal) }
          ],
          label: {
            position: 'insideStart'
          },
          symbolSize: 0,
          lineStyle: {
            type: 'solid',
            width: 1,
            color: this.gadgetSetting.goalcolor
          }
        }
      })
    },
    resetOptions (val, data) {
      val.series.push(JSON.parse(JSON.stringify(val.series[val.series.length - 1])))
      val.series[val.series.length - 1].type = 'line'
      val.series[val.series.length - 1].name = this.gadgetSetting.valueFieldsNameMeasureL
      val.series[val.series.length - 1].data.forEach((item, index) => {
        item.value = data[index][this.gadgetSetting.valueFieldsNameMeasureL]
      })
      return val
    },
    updateSqlChart (originData) {
      this.chartDom = document.getElementById(`${this.selfGadgetUuid}`)
      if (!this.chartDom) {
        setTimeout(() => {
          this.repeatNumber++
          this.updateSqlChart(originData)
        }, 1000)
      } else {
        this.chartOption = this.$options.data.call(this).chartOption
        this.repeatNumber = 0
        let myChart = Echarts.init(this.chartDom, this.globalTheme)
        this.chartOption.title.text = this.gadgetSetting.title
        this.chartOption.xAxis.name = this.gadgetSetting.xName
        this.chartOption.yAxis.name = this.gadgetSetting.yName

        let tempX = []
        let tempGroup = []
        for (let i = 0; i < originData.length; i++) {
          tempX.push(originData[i][this.gadgetSetting.valueFieldsNameMeasureX])
          tempGroup.push(originData[i][this.gadgetSetting.valueFieldsNameMeasureGroup])
        }
        tempX = this._.uniq(tempX)
        tempGroup = this._.uniq(tempGroup)
        this.chartOption.xAxis.data = tempX
        this.chartOption.legend.data = tempGroup
        let lastList = []
        for (let i = 0; i < tempGroup.length; i++) {
          const groupItem = tempGroup[i]
          lastList.push({
            name: groupItem,
            type: 'bar',
            barGap: '10%',
            label: {
              show: true,
              formatter: '{c}'
            },
            data: []
          })
          for (let ii = 0; ii < originData.length; ii++) {
            const item = originData[ii]
            if (item[this.gadgetSetting.valueFieldsNameMeasureGroup] === groupItem) {
              lastList[i].data[tempX.findIndex(e => e === item[this.gadgetSetting.valueFieldsNameMeasureX])] = item[this.gadgetSetting.valueFieldsNameMeasureY]
            }
          }
          if (lastList[lastList.findIndex(e => e.name === groupItem)].data.length === 0) {
            lastList.splice(lastList.findIndex(e => e.name === groupItem), 1)
          }
          this.chartOption.series = lastList
        }

        if (this.gadgetSetting.type === 'StackingColumn') {
          for (let i = 0; i < this.chartOption.series.length; i++) {
            this.chartOption.series[i]['stack'] = 'stack'
          }
        }
        if (this.gadgetSetting.type === 'Bar') {
          let oldX = this._.cloneDeep(this.chartOption.xAxis)
          let oldY = this._.cloneDeep(this.chartOption.yAxis)
          this.chartOption.xAxis = oldY
          this.chartOption.yAxis = oldX
          this.chartOption.yAxis.nameRotate = 0
          this.chartOption.yAxis.axisLabel.rotate = 0
          this.chartOption.xAxis.nameGap = 10
          this.chartOption.xAxis.nameRotate = -90
        }
        if (this.gadgetSetting.valueFieldsNameMeasureL) {
          this.chartOption = this.resetOptions(this.chartOption, originData)
        }
        if (this.gadgetSetting.color.length > 0) {
          this.chartOption.color = this.gadgetSetting.color
        }
        if (this.gadgetSetting.goal && this.gadgetSetting.goalcolor) {
          this.chartOption.series.unshift({
            data: new Array(this.chartOption.series[0].data.length).fill(Number(this.gadgetSetting.goal)),
            type: 'line',
            symbolSize: 0,
            lineStyle: {
              width: 1,
              color: this.gadgetSetting.goalcolor
            }
          })
        }
        if (this.gadgetSetting.showYaxisRight) {
          if (this.gadgetSetting.type === 'Bar') {
            this.setXaxisRight(this.chartOption)
          } else {
            this.setYaxisRight(this.chartOption)
            this.chartOption.xAxis.nameGap = 25
          }
        }
        this.setLabel(this.chartOption)
        myChart.setOption(this.chartOption)
        this.$erd.listenTo(this.chartDom, element => {
          this.$nextTick(() => {
            this.resized()
          })
        })
      }
    },
    setLabel (val) {
      val.series.forEach(item => {
        if (item.label) {
          item.label.show = this.gadgetSetting.showlabel
        }
      })
    },
    setYaxisRight (val) {
      val.series.forEach((item, index) => {
        var res = this.gadgetSetting.useRightyAxis.some(i => i === item.name)
        if (res) {
          item.yAxisIndex = 1
        } else {
          item.yAxisIndex = 0
        }
      })
      var temp = val.yAxis
      val.yAxis = []
      val.yAxis.push(temp)
      val.yAxis.push({
        type: 'value',
        name: this.gadgetSetting.YaxisRightLabel,
        min: this.gadgetSetting.yAxismin,
        max: this.gadgetSetting.yAxismax,
        position: 'right',
        // axisLabel: {
        //   formatter: '{value}' // 61A0A8
        // },
        axisLabel: {
          formatter: this.gadgetSetting.rightyAxisPercentage ? (value) => {
            return value * 100 + '%'
          } : '{value}' // 61A0A8
        },
        axisLine: {
          lineStyle: {
            color: '#61A0A8'
          }
        },
        nameTextStyle: {
          align: 'right'
        }
      })
      const data1 = val.series[0].data.map(i => i.value)
      const data2 = val.series[1].data.map(i => i.value)
      const rowNum = val.series[0].data.length
      let max1 = Math.max(...data1)
      let max2 = Math.max(...data2)
      let min1 = Math.min(...data1)
      let min2 = Math.min(...data2)
      const rat1 = min1 / max1
      const rat2 = min2 / max2
      /* 比例大小对比 */
      const ratState = rat1 > rat2
      /* 设置极小值 */
      if (ratState) {
        min1 = rat2 * max1
      } else {
        min2 = rat1 * max2
      }
      const inter1 = Math.ceil((max1 - min1) / rowNum)
      const inter2 = Math.ceil((max2 - min2) / rowNum)
      min1 = Math.floor(min1 / inter1) * inter1
      max1 = Math.ceil(max1 / inter1) * inter1
      min2 = Math.floor(min2 / inter2) * inter2
      max2 = Math.ceil(max2 / inter2) * inter2
      val.yAxis[0].scale = true
      val.yAxis[0].min = min1
      val.yAxis[0].max = max1
      val.yAxis[0].interval = inter1
      val.yAxis[1].scale = true
      val.yAxis[1].min = min2
      val.yAxis[1].max = max2
      val.yAxis[1].interval = inter2
    },
    setXaxisRight (val) {
      val.series.forEach((item, index) => {
        var res = this.gadgetSetting.useRightyAxis.some(i => i === item.name)
        if (res) {
          item.xAxisIndex = 1
        } else {
          item.xAxisIndex = 0
        }
      })
      var temp = val.xAxis
      val.xAxis = []
      val.xAxis.push(temp)
      val.xAxis.push({
        type: 'value',
        name: this.gadgetSetting.YaxisRightLabel,
        min: this.gadgetSetting.yAxismin,
        max: this.gadgetSetting.yAxismax,
        position: 'right',
        // axisLabel: {
        //   formatter: '{value}' // 61A0A8
        // },
        axisLabel: {
          formatter: this.gadgetSetting.rightyAxisPercentage ? (value) => {
            return value * 100 + '%'
          } : '{value}' // 61A0A8
        },
        axisLine: {
          lineStyle: {
            color: '#61A0A8'
          }
        }
      })
      const data1 = val.series[0].data.map(i => i.value)
      const data2 = val.series[1].data.map(i => i.value)
      const rowNum = val.series[0].data.length
      let max1 = Math.max(...data1)
      let max2 = Math.max(...data2)
      let min1 = Math.min(...data1)
      let min2 = Math.min(...data2)
      const rat1 = min1 / max1
      const rat2 = min2 / max2
      /* 比例大小对比 */
      const ratState = rat1 > rat2
      /* 设置极小值 */
      if (ratState) {
        min1 = rat2 * max1
      } else {
        min2 = rat1 * max2
      }
      const inter1 = Math.ceil((max1 - min1) / rowNum)
      const inter2 = Math.ceil((max2 - min2) / rowNum)
      min1 = Math.floor(min1 / inter1) * inter1
      max1 = Math.ceil(max1 / inter1) * inter1
      min2 = Math.floor(min2 / inter2) * inter2
      max2 = Math.ceil(max2 / inter2) * inter2
      val.xAxis[0].scale = true
      val.xAxis[0].min = min1
      val.xAxis[0].max = max1
      val.xAxis[0].interval = inter1
      val.xAxis[1].scale = true
      val.xAxis[1].min = min2
      val.xAxis[1].max = max2
      val.xAxis[1].interval = inter2
    },
    queryModelClosed () {
      this.queryModelDefaultSetting.showSetting = false
      this.query()
    },
    showQueryModel () {
      this.queryModelDefaultSetting.showSetting = true
    },
    resized (i, newH, newW, newHPx, newWPx) {
      setTimeout(() => {
        let myChart = Echarts.init(this.chartDom, this.globalTheme)
        myChart.resize()
      }, 0)
    },
    containerResizedEvent (i, newH, newW, newHPx, newWPx) {
      this.chartWidth = (newWPx - 10) + 'px'
    },
    upgradeGadgetSetting (setting) {

    },
    getRegressionChart (chartData, chartTitle, chartId, regType, regOrder, myChart) {
      let regressionDemo = ecStat.regression(regType, chartData, regOrder)
      regressionDemo.points.sort(function (a, b) {
        return a[0] - b[0]
      })

      return {
        name: 'line',
        type: 'line',
        showSymbol: false,
        lineStyle: {
          // type: "dashed",
          color: '#f00'
        },
        data: regressionDemo.points
      }
    },
    query (e) {
      this.gadgetSetting = this._.merge(this.gadgetSetting, this.queryModelDefaultSetting.dataInfo.gadgetSetting)
      if (e !== 'auto') {
        this.loading = true
      }
      var _self = this
      var obj = JSON.parse(JSON.stringify(this.slicer))
      let tempObj = this.returnReportLinkParam()
      if (tempObj['name'] && this.slicer['name'] && tempObj['name'] === this.slicer['name']) delete this.slicer['name']
      for (var key in obj) {
        if (key === 'id') {
          delete obj.id
        }
      }
      var param = {
        ...obj,
        code: this.code,
        gadgettype: this.wgadgettype,
        widgetName: this.wName,
        slicer: { ...this.slicer },
        pageId: this.pageId,
        gadgetId: this.id,
        filter: this.getFilterStr(),
        type: this.filterType
      }
      this.$interface.reports.getReportDataInfo(param).then(({ data: res }) => {
        try {
          _self.$parent.$parent.$parent.$parent.$parent.$parent.selectFields = res.selectFields
        } catch (error) {

        }
        this.currentTime = new Date()
        _self.verifyHasData(res)
        if (res.config) {
          _self._.merge(_self.gadgetSetting, res.config)
          if (!_self.gadgetSetting.headerDescription || _self.gadgetSetting.headerDescription === null) {
            _self.gadgetSetting.headerDescription = ''
          }
          _self.upgradeGadgetSetting(_self.gadgetSetting)
        }

        if (res.name) {
          _self.widgetName = res.name
        } else if (this.wName){
          _self.widgetName = this.wName
        }  else {
          _self.widgetName = _self.gadgetSetting.headerTitle
        }
        this.fxFields = res.fxFields || []
        if (res.data) {
          this.currentTime = new Date()
          _self.queryData = res.data
          _self.queryFields = res.selectFields
          _self.conditionFormat = res.conditionFormat.reverse()
          _self.linkedDatasetList = res.datasetSync
          if (Array.isArray(this.queryFields) && this.queryFields.length === 0 && (Array.isArray(res.data) && res.data.length > 0)) {
            _self.updateSqlChart(res.data)
          } else {
            _self.updateChart(res.data)
          }
        }
      }).catch((error) => {
         if (this.wName) {
          this.widgetName = this.wName
        }
        Echarts.init(this.chartDom).dispose()
        this.isHasData = false
        _self.loading = false
        if (error.response && error.response.status === 504) {
          this.errorStatus = '504'
          this.gadgetMessageBus.$emit(this.pageId + 'stopautorefresh')
        }
      }).finally(() => {
        this.autoRefreshQuery(e)
        this.updateGadgetLoadingStatus(!this.loading)
      })
    },
    load (args) {
      args.chart.series[0].marker.dataLabel.font.color = '#000000'
    }
  }
})
</script>
<style lang="scss" scoped>
.content-wrapper {
  position: relative;
  .gadget-no-newdata {
    position: absolute;
    top: 40%;
    left: 0;
    right: 0;
    margin: 0 auto;
    .widgets-no-data {
      display: flex;
      flex-direction: column;
      align-items: center;
      .widgets-tip {
        margin-top: 5px;
      }
    }
  }
}
</style>
<style scoped>
.el-card ::v-deep .el-card__body {
  padding: 0px !important;
}

.el-card ::v-deep .el-divider--horizontal {
  margin: 3px 0 !important;
}

.threepoints {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 20px;
  border-bottom: 1px solid #eee;
  position: relative;
}

.cardTitle {
  font-size: 16px;
  color: #000;
  font-weight: 700;
  display: inline-block;
  max-width: calc(100% - 30px);
  position: relative;
  top: 2px;
}

.cardIcon {
  font-size: 16px;
  font-weight: 600;
  margin-left: 10px;
  position: relative;
  top: -2px;
}
</style>
<style lang="scss">
.bar-gadget-css {
  .el-card__body {
    width: 100%;
    height: 100%;
  }
  .control-section2 {
    width: 100%;
    height: calc(100% - 34px);
  }
}
</style>
